package com.syni.mdd.sjb.common.datatreaure.controller.protect;

import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckUserIdentity;
import com.syni.mdd.sjb.common.datatreaure.controller.BaseController;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.services.*;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppBannerService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppServiceOrderService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppServiceSonService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppServicesService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/services")
public class ServiceController extends BaseController {
    @Autowired
    DxshAppBannerService dxshAppBannerService;

    @Autowired
    DxshAppServiceSonService dxshAppServiceSonService;

    @Autowired
    DxshAppServicesService dxshAppServicesService
            ;
    @Autowired
    DxshAppServiceOrderService dxshAppServiceOrderService;

    @PostMapping("data")
    @ApiOperation(value = "电享生活商户端APP服务首页")
    @CheckUserIdentity
    public Map<String,Object> data(){
        return dxshAppServicesService.data();
    }

    @PostMapping("getBanner")
    @ApiOperation(value = "服务模块轮播图")
    @CheckUserIdentity
    public Map<String,Object> getBanner(){
        return dxshAppBannerService.getBanner();
    }

    @PostMapping("getSonsByFatherId")
    @ApiOperation(value = "根据父类ID获取子类标签")
    @ApiImplicitParams(@ApiImplicitParam(name ="fatherId", value = "父类ID"))
    @CheckUserIdentity
    public Map<String,Object> getSonsByFather(@RequestBody @Validated GetSonsByFatherRqVo getSonsByFatherRqVo){
        return dxshAppServiceSonService.getSonsByFather(getSonsByFatherRqVo);
    }

    @PostMapping("getServicesBySonId")
    @ApiOperation(value = "根据子类ID获取服务列表")
    @ApiImplicitParams({@ApiImplicitParam(name ="sonId",value = "子类ID"),
                        @ApiImplicitParam(name = "pageSize",value = "每页数量"),
                        @ApiImplicitParam(name = "pageNum",value = "页码")})
    @CheckUserIdentity
    public Map<String,Object> getServicesBySonId(@RequestBody @Validated GetServicesBySonIdRqVo getServicesBySonIdRqVo){
        return dxshAppServicesService.getServicesBySonId(getServicesBySonIdRqVo);
    }

    @PostMapping("getServicesById")
    @ApiOperation(value = "根据ID获取服务详情")
    @ApiImplicitParams(@ApiImplicitParam(name ="serviceId",value = "服务ID"))
    @CheckUserIdentity
    public Map<String,Object> getServicesById(@RequestBody @Validated GetServicesByIdRqVo getServicesByIdRqVo){
        return dxshAppServicesService.getServicesById(getServicesByIdRqVo);
    }

    @PostMapping("search")
    @ApiOperation(value = "搜索服务")
    @ApiImplicitParams(@ApiImplicitParam(name ="searchName",value = "搜索名字"))
    @CheckUserIdentity
    public Map<String,Object> search(@RequestBody @Validated SearchRqVo searchRqVo){
        return dxshAppServicesService.search(searchRqVo);
    }

    @PostMapping("myServices")
    @ApiOperation(value = "获取我的服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize",value = "每页数量"),
            @ApiImplicitParam(name = "pageNum",value = "页码")
    })
    @CheckUserIdentity
    public Map<String,Object> myServices(@RequestBody @Validated MyServicesVo myServicesVo){
        return dxshAppServicesService.myServices(myServicesVo);
    }

    @PostMapping("getMyServicesList")
    @ApiOperation(value = "获取我的服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize",value = "每页数量"),
            @ApiImplicitParam(name = "pageNum",value = "页码")
    })
    @CheckUserIdentity
    public Map<String,Object> getMyServicesList(@RequestBody @Validated MyServicesVo myServicesVo){
        return dxshAppServicesService.getMyServicesList(myServicesVo);
    }


    @PostMapping("deleteByOrderId")
    @ApiOperation(value = "删除订单服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId",value = "订单ID"),
    })
    @CheckUserIdentity
    public Map<String,Object> deleteByOrderId(@RequestBody @Validated GetOrderIdRqVo getOrderIdRqVo){
        return dxshAppServiceOrderService.deleteByOrderId(getOrderIdRqVo);
    }
}
